package com.princess.demok.view

import android.content.Context
import android.util.AttributeSet
import android.view.MotionEvent
import android.widget.RelativeLayout
import com.princess.baselib.utils.LogUtils

/**
 * @author: xha
 * @date: 2021/9/16 11:48
 * @Description:
 */
class MyRElativeview : RelativeLayout {

    var viewGroupDispatchTouchEventInt: Int = 0
    var viewGroupOnInterceptTouchEventInt: Int = 0

    constructor(context: Context) : super(context) {
    }

    constructor(context: Context, attributeSet: AttributeSet) : super(context, attributeSet) {

    }

    constructor(context: Context, attributeSet: AttributeSet, defStyleAttr: Int) : super(
        context,
        attributeSet,
        defStyleAttr
    ) {

    }

    override fun dispatchTouchEvent(ev: MotionEvent?): Boolean {
        return when (viewGroupDispatchTouchEventInt) {
            0 -> {
                LogUtils.i("touch", "viewGroup1 dispatchTouchEvent " + super.dispatchTouchEvent(ev))
                super.dispatchTouchEvent(ev)
            }
            1 -> {
                val isTure = true
                LogUtils.i("touch1", "viewGroup1 dispatchTouchEvent $isTure")
                isTure
            }
            else -> {
                val isTure = false
                LogUtils.i("touch1", "viewGroup1 dispatchTouchEvent $isTure")
                isTure
            }
        }


    }

    override fun onInterceptTouchEvent(ev: MotionEvent?): Boolean {
        return when (viewGroupDispatchTouchEventInt) {
            0 -> {
                LogUtils.i(
                    "touch",
                    "viewGroup1 dispatchTouchEvent " + super.onInterceptTouchEvent(ev)
                )
                super.onInterceptTouchEvent(ev)
            }
            1 -> {
                val isTure = true
                LogUtils.i("touch1", "viewGroup11 onInterceptTouchEvent $isTure")
                isTure
            }
            else -> {
                val isTure = false
                LogUtils.i("touch1", "viewGroup1 dispatchTouchEvent $isTure")
                isTure
            }
        }
    }

    override fun onTouchEvent(event: MotionEvent?): Boolean {
        LogUtils.i("touch", "viewGroup1 onTouchEvent " + super.onTouchEvent(event))
        return super.onTouchEvent(event)

    }


}